/*
 * $Log: $
 */
package com.rock.code.datacollconfig.coll.service.impl;


import com.rock.code.common.util.ServerStart;
import com.rock.code.common.util.SpringContext;
import com.rock.code.datacollconfig.coll.service.DataCollInstanceThread;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Title: DataItemSchedulerzStart<br>
 * Description: <br>
 * 
 * @author Huosd
 * @createDate May 25, 2012
 */
@Component
public class DataCollSchedulerzStart implements ServerStart {

	@Resource
	private DataCollInstanceThread dataCollInstanceThread;
	private Log logger = LogFactory.getLog(getClass());
	private int threadNum = 1;

	@Override
	public void start() {
		logger.info("DataCollInstanceThread starting...");
		for (int i = 0; i < threadNum; i++) {
			try {
				dataCollInstanceThread = (DataCollInstanceThread) SpringContext
						.getBean("dataCollInstanceThread");
				dataCollInstanceThread.start();
			} catch (Exception exception) {
				logger.error("DataCollInstanceThread error", exception);
			}
		}
		logger.info("DataCollInstanceThread success.");
	}

	public DataCollInstanceThread getDataCollInstanceThread() {
		return dataCollInstanceThread;
	}

	public void setDataCollInstanceThread(
			DataCollInstanceThread dataCollInstanceThread) {
		this.dataCollInstanceThread = dataCollInstanceThread;
	}

	public Log getLogger() {
		return logger;
	}

	public void setLogger(Log logger) {
		this.logger = logger;
	}

	public int getThreadNum() {
		return threadNum;
	}

	public void setThreadNum(int threadNum) {
		this.threadNum = threadNum;
	}
}
